package com.iotechn.unimall.admin.api.warehouseGoods;

import com.iotechn.unimall.core.annotation.HttpMethod;
import com.iotechn.unimall.core.annotation.HttpOpenApi;
import com.iotechn.unimall.core.annotation.HttpParam;
import com.iotechn.unimall.core.annotation.HttpParamType;
import com.iotechn.unimall.core.annotation.param.NotNull;
import com.iotechn.unimall.core.annotation.param.Range;
import com.iotechn.unimall.core.annotation.param.TextFormat;
import com.iotechn.unimall.core.exception.ServiceException;
import com.iotechn.unimall.data.domain.WarehouseGoodsDO;
import com.iotechn.unimall.data.model.Page;

import java.util.List;

/**
 * 库存商品表
 *
 * @author wxw
 * @email
 * @date 2020-03-24 17:22:46
 */
@HttpOpenApi(group = "admin.warehouseGoods", description = "")
public interface WarehouseGoodsService {

    @HttpMethod(description = "列表", permission = "warehouse:warehousegoods:list", permissionParentName = "仓库管理", permissionName = "库存查询")
    Page<WarehouseGoodsDO> list(
            @HttpParam(name = "pageNo", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer page,
            @HttpParam(name = "limit", type = HttpParamType.COMMON, description = "页长度", valueDef = "20") Integer limit,
            @HttpParam(name = "title", type = HttpParamType.COMMON, description = "商品信息") String title,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @HttpParam(name = "warehouseId") Long warehouseId, @HttpParam(name = "skuId") Long skuId) throws ServiceException;

    @HttpMethod(description = "创建")
    WarehouseGoodsDO create(
            @NotNull @HttpParam(name = "warehouseGoodsDO", type = HttpParamType.COMMON, description = "") WarehouseGoodsDO warehouseGoodsDO,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "修改")
    String update(
            @NotNull @HttpParam(name = "warehouseGoodsDO", type = HttpParamType.COMMON, description = "") WarehouseGoodsDO warehouseGoodsDO,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "删除")
    String delete(
            @NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "删除Id") Long id,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "详情", permission = "warehouse:warehousegoods:detail", permissionParentName = "仓库管理", permissionName = "库存查询")
    WarehouseGoodsDO detail(
            @NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "Id") Long id,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;


    @HttpMethod(description = "商品所在库存列表", permission = "warehouse:warehousegoods:list", permissionParentName = "仓库管理", permissionName = "库存查询")
    List<WarehouseGoodsDO> goodsListByWarehouse(
            @HttpParam(name = "skuId", type = HttpParamType.COMMON, description = "", valueDef = "") Long skuId,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;


    @HttpMethod(description = "仓库预警设置列表")
    Page<WarehouseGoodsDO> listGoodsAlarm(
            @HttpParam(name = "pageNo", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer page,
            @HttpParam(name = "limit", type = HttpParamType.COMMON, description = "页长度", valueDef = "20") Integer limit,
            @HttpParam(name = "title", type = HttpParamType.COMMON, description = "商品信息") String title,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @HttpParam(name = "warehouseId", description = "仓库id") Long warehouseId) throws ServiceException;

    @HttpMethod(description = "更新仓库预警设置")
    String updateGoodsAlarm(@HttpParam(name = "id", description = "仓库商品id") Long id, @TextFormat(regex = "^[+]?([0-9]+(.[0-9]{1,2})?)$") @HttpParam(name = "alarm", description = "预警", valueDef = "0") Float alarm) throws ServiceException;

    @HttpMethod(description = "列出预警的商品（分页）")
    Page<WarehouseGoodsDO> listStockAlarmGoods(
            @HttpParam(name = "pageNo", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer page,
            @HttpParam(name = "limit", type = HttpParamType.COMMON, description = "页长度", valueDef = "20") Integer limit,
            @HttpParam(name = "title", type = HttpParamType.COMMON, description = "商品信息") String title,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @HttpParam(name = "warehouseId", description = "仓库id") Long warehouseId) throws ServiceException;

    @HttpMethod(description = "列出预警的商品")
    List<WarehouseGoodsDO> listStockAlarmGoodsByPara(@HttpParam(name = "title", type = HttpParamType.COMMON, description = "商品信息") String title,
                                                     @Range(min = 5) @HttpParam(name = "limit", description = "前几条(默认5条)", valueDef = "5") Integer limit,
                                                     @HttpParam(name = "warehouseId", description = "仓库id") Long warehouseId);

}

